<template>
    <div class="sj-file">
        <div class="operation"><el-button v-if="jurisdiction.addBaseInfo" @click="insertList" class="slot-btn-top" type="primary" size="small">新增</el-button></div>
        <el-table :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
                  stripe
                  border
                  class="user-table"
                  :height="tableHeight"
                  style="width: 100%;"
                  :header-cell-style="getRowClass"
        >
            <el-table-column fixed type="index" label="*" sortable align="center" min-width="40"></el-table-column>
            <el-table-column prop="fileName" label="文件名称" sortable min-width="200"></el-table-column>
            <el-table-column prop="fileCode" label="文件编码" sortable min-width="200"></el-table-column>
            <el-table-column prop="versionCode" label="版本号" sortable min-width="200"></el-table-column>
            <el-table-column prop="fileWriterName" label="创建人" sortable min-width="110"></el-table-column>
            <el-table-column prop="createTime" label="创建时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="fileApproverName" label="发布人" sortable min-width="110"></el-table-column>
            <el-table-column prop="approvalTime" label="发布时间" sortable min-width="170"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="right" min-width="140">
                <template slot-scope="scope">
                    <el-button @click="openPrint(scope.row)" type="text" size="small">查看</el-button>
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                    <el-button @click="getRecordData(scope.row)" type="text" size="small">记录</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
                background
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[5,10, 15,20, 25,30,50, 100]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="tableData.length">
        </el-pagination>

        <!-- 基本信息 -->
        <el-dialog :title="dialogTitle" width="75%" top="50px" :visible.sync="isDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;">
                <el-tab-pane label="基本信息" name="first" :style="dialogHeight">
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="120px" :model="dialogList">
                        <el-form-item label="文件名称"><el-input v-model="dialogList.fileName" :disabled="isDialogLockedDisabled"></el-input></el-form-item>
                        <el-form-item label="文件编码"><el-input v-model="dialogList.fileCode" :disabled="isDialogLockedDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="版本号">
                            <el-input v-model="dialogList.versionCode" :disabled="isDialogLockedDisabled"></el-input>
                        </el-form-item>
                        <el-form-item label="修订次数">
                            <el-input v-model="dialogList.updateTimes" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件创建人">
                            <el-input v-model="dialogList.fileWriterName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="创建日期">
                            <el-input v-model="dialogList.createTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="最后修改日期">
                            <el-input v-model="dialogList.lastUpdateTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="所属文件夹">
                            <el-input v-model="dialogList.fileGs" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件发布人">
                            <el-input v-model="dialogList.fileApproverName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="文件是否发布">
                            <el-select v-model="dialogList.isApproval" :disabled="isApprovalDisabled">
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="相关部门">
                            <el-select v-model="dialogList.fileUseScope" multiple placeholder="请选择" :disabled="isDialogLockedDisabled">
                                <el-option
                                        v-for="item in departments"
                                        :key="item.id"
                                        :label="item.deptName"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="120px" :model="dialogList">
                        <el-form-item label="内容" style="width: 99%;">
                            <!--<quill-editor v-model="dialogList.initialContent"></quill-editor>-->
                            <vue-ueditor-wrap v-model="dialogList.initialContent" :config="config"></vue-ueditor-wrap>
                        </el-form-item>
                    </el-form>
                    <div v-if="jurisdiction.fileRelease" style="text-align: right;" ><el-button v-if="isDialogDisabled" @click="submitList" type="primary">确 定</el-button></div>
                </el-tab-pane>
                <el-tab-pane v-if="dialogTitle !== '添加'" label="附件" name="second" :style="dialogHeight">
                    <!-- 附件上传按钮 -->
                    <div style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo" style="width: 99%;margin: 0 auto;" ref="uploadEnclosure" :action="enclosureSrc" :data="resEnclosureData" :headers="headers" :auto-upload="false" :limit="1" :on-success="uploadEnclosureSuccess">
                            <el-button v-if="jurisdiction.addEditApplyInfo"  slot="trigger" size="small" type="primary">上传附件</el-button>
                        </el-upload>
                    </div>
                    <el-form label-position="right" label-width="110px" :model="enclosureData">
                        <el-form-item label="文件描述"><el-input v-model="enclosureData.fileDesc" @blur="changeFileDesc" type="textarea" style="padding-right: 10px;box-sizing: border-box;"></el-input></el-form-item>
                    </el-form>
                    <div style="margin-top: 20px;text-align: right;padding-right: 10px;"><el-button v-if="jurisdiction.addEditApplyInfo"  @click="submitDialogEnclosureDataOther" type="primary">提交</el-button></div>

                    <!-- 附件列表 -->
                    <h3 class="dialog-plate-title" style="margin: 30px 0 10px;padding-right: 10px;box-sizing: border-box;"><span>已上传附件列表</span></h3>
                    <el-table :data="enclosureList" stripe border class="user-table" height="550" style="width: 99%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="fileName" label="文件名称" sortable min-width="300"></el-table-column>
                        <el-table-column prop="uploadPersonName" label="文件上传人" sortable min-width="130"></el-table-column>
                        <el-table-column prop="uploadTime" label="文件上传时间" sortable min-width="170"></el-table-column>
                        <el-table-column prop="fileDesc" label="文件描述" sortable min-width="400"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="right" min-width="90">
                            <template slot-scope="scope">
                                <el-button v-if="jurisdiction.addEditApplyInfo"  @click="downloadAppendix(scope.row.id)" type="text" size="small">下载</el-button>
                                <el-button @click="deleteAppendix(scope.row)" type="text" size="small">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>

        <!-- 记录 -->
        <el-dialog title="记录" width="85%" top="60px" :visible.sync="isDialogRecord" :close-on-click-modal="false">
            <el-tabs v-model="activeRecordName" @tab-click="handleRecordClick" style="padding-bottom: 15px;">
                <el-tab-pane label="申请修改记录" name="first">
                    <el-button v-if="jurisdiction.addEditApplyInfo"  @click="insertRecord" type="primary" icon="el-icon-plus" size="mini">新增申请修改</el-button>
                    <el-table :data="dialogApplyData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="user-table" :height="tableRecordHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="fileCode" label="文件编码" sortable min-width="150"></el-table-column>
                        <el-table-column prop="versionCode" label="版本号" sortable min-width="150"></el-table-column>
                        <el-table-column prop="applicantName" label="申请人" sortable min-width="110"></el-table-column>
                        <el-table-column prop="applyTime" label="申请时间" :formatter="formatIsNull" sortable min-width="170"></el-table-column>
                        <el-table-column prop="approvalResult" label="申请结果" :formatter="formatIsResult" sortable min-width="110"></el-table-column>
                        <el-table-column prop="isTrain" label="是否需要培训" :formatter="formatNeedTrain" sortable min-width="150"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="right" min-width="170">
                            <template slot-scope="scope">
                                <el-button v-if="jurisdiction.addEditApplyInfo" @click="updateRecord(scope.row)" type="text" size="small">编辑</el-button>
                                <el-button v-if="jurisdiction.auditingApply"  @click="openExamine(scope.row)" type="text" size="small">审核</el-button>
                                <el-button @click="openExamineHistory(scope.row)" type="text" size="small">历史记录</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="dialogApplyData.length"></el-pagination>
                </el-tab-pane>
                <el-tab-pane label="回收与发放记录" name="second">
                    <el-button v-if="jurisdiction.addPrintGrantInfo" @click="insertGrantRecoveryData" type="primary" icon="el-icon-plus" size="mini">新增发放</el-button>
                    <el-table :data="tableGrantRecoveryData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="user-table" :height="tableRecordHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                        <el-table-column prop="versionCode" label="版本号" sortable width="170"></el-table-column>
                        <el-table-column prop="issuerName" label="发放人" sortable width="120"></el-table-column>
                        <el-table-column prop="num" label="发放数量" sortable width="120"></el-table-column>
                        <el-table-column prop="accepterName" label="接收人" sortable width="110"></el-table-column>
                        <el-table-column prop="acceptTime" label="接收时间" sortable width="170"></el-table-column>
                        <el-table-column prop="recyclingPersonName" label="回收人" sortable width="110"></el-table-column>
                        <el-table-column prop="recyclingTime" label="回收时间" sortable width="170"></el-table-column>
                        <el-table-column prop="recyclingVersionCode" label="回收号" sortable width="170"></el-table-column>
                        <el-table-column prop="remark" label="备注" sortable width="350"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                            <template slot-scope="scope">
                                <el-button v-if="jurisdiction.addPrintGrantInfo" @click="updateGrantRecoveryData(scope.row)" type="text" size="small">回收</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="tableGrantRecoveryData.length"></el-pagination>
                </el-tab-pane>
                <el-tab-pane label="培训记录" name="third">
                    <el-table :data="tableTrainData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="user-table" :height="tableRecordHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable width="40"></el-table-column>
                        <el-table-column prop="versionCode" label="版本号" sortable width="180"></el-table-column>
                        <el-table-column prop="trainerName" label="培训主持人" sortable width="130"></el-table-column>
                        <el-table-column prop="trainTime" label="培训时间" sortable width="170"></el-table-column>
                        <el-table-column prop="studyPersons" label="培训参与人" sortable width="1100"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                            <template slot-scope="scope">
                                <el-button v-if="jurisdiction.addEditApplyInfo" @click="updateTrainData(scope.row)" type="text" size="small">修改</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="tableTrainData.length"></el-pagination>
                </el-tab-pane>
                <el-tab-pane label="版本记录" name="four">
                    <el-table :data="tableEditionData.slice((currentPage-1)*pagesize,currentPage*pagesize)" stripe border class="user-table" :height="tableRecordHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="versionCode" label="版本号" sortable min-width="180"></el-table-column>
                        <el-table-column prop="fileCode" label="文件编码" sortable min-width="180"></el-table-column>
                        <el-table-column prop="issuer" label="发布人" sortable min-width="130"></el-table-column>
                        <el-table-column prop="issueTime" label="发布时间" sortable min-width="170"></el-table-column>
                        <el-table-column prop="versionDesc" label="版本描述" sortable min-width="400"></el-table-column>
                        <el-table-column fixed="right" label="操作" align="right" min-width="120">
                            <template slot-scope="scope">
                                <el-button v-if="jurisdiction.addEditApplyInfo" @click="EditedVersionData(scope.row)" type="text" size="small">编辑</el-button>
                                <el-button @click="updateEditionData(scope.row)" type="text" size="small">查看</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25, 30 ,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="tableEditionData.length"></el-pagination>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>

        <!-- 申请记录 -->
        <el-dialog :title="dialogApplyTitle" width="70%" top="50px" class="apply-dialog" :visible.sync="isApplyDialog" :close-on-click-modal="false">
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px" :model="dialogApplyList">
                <el-form-item label="申请人"><el-input v-model="dialogApplyList.applicantName" disabled></el-input></el-form-item>
                <el-form-item label="申请时间"><el-input v-model="dialogApplyList.applyTime" disabled></el-input></el-form-item>
                <el-form-item label="文件编码"><el-input v-model="dialogApplyList.fileCode" :disabled="dialogApplyList.approvalResult === '1'"></el-input></el-form-item>
                <el-form-item label="版本号"><el-input v-model="dialogApplyList.versionCode" :disabled="dialogApplyList.approvalResult === '1'"></el-input></el-form-item>
                <el-form-item label="是否需要培训"><el-select v-model="dialogApplyList.isTrain" :disabled="dialogApplyList.approvalResult === '1'" >
                        <el-option label="否" value="0"></el-option>
                        <el-option label="是" value="1"></el-option></el-select>
                </el-form-item>
            </el-form>
            <el-form label-position="right" label-width="110px" :model="dialogApplyList">
                <el-form-item label="申请内容">
                    <quill-editor v-model="dialogApplyList.initialContent"></quill-editor>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="submitRecord" type="primary">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 申请审核/历史记录弹框 -->
        <el-dialog :title="dialogExamineTitle" :width="dialogExamineWidth" top="60px" class="Examine-dialog"
                   :visible.sync="isExamineDialog" :close-on-click-modal="false">
            <!-- 申请审核表格-->
            <div v-if="dialogExamineTitle ==='审核列表' " style="padding-bottom: 20px;">
                <h3 class="dialog-plate-title" style="margin: 10px 0;"><span>审核部门列表</span></h3>
                <el-table :data="tableExamineData" stripe border height="300px" class="user-table" style="width: 100%;"
                          :header-cell-style="getRowClass">
                    <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                    <el-table-column prop="deptName" label="审核部门" sortable min-width="160"></el-table-column>
                    <el-table-column prop="approvalerName" label="审核人" :formatter="formatIsNull" sortable
                                     min-width="110"></el-table-column>
                    <el-table-column prop="approvalTime" label="审核时间" :formatter="formatIsNull" sortable
                                     min-width="170"></el-table-column>
                    <el-table-column prop="isApproval" label="审核结果" :formatter="formatIsResult" sortable
                                     min-width="110"></el-table-column>
                    <el-table-column prop="approvalAdvice" label="审核意见" :formatter="formatIsNull" sortable
                                     min-width="300"></el-table-column>
                    <el-table-column fixed="right" label="操作" sortable align="right" width="80">
                        <template slot-scope="scope">
                            <el-button @click="goExamine(scope.row)" type="text" size="small">审核</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <h3 v-if="isSubmitExamine" class="dialog-plate-title" style="margin: 20px 0 10px;"><span>审核操作</span></h3>
                <div v-if="isSubmitExamine" style="padding-bottom: 20px;">
                    <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                             :model="dialogExamineList">
                        <el-form-item label="审核人">
                            <el-input v-model="dialogExamineList.approvalerName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核时间">
                            <el-input v-model="dialogExamineList.approvalTime" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核部门">
                            <el-input v-model="dialogExamineList.deptName" disabled></el-input>
                        </el-form-item>
                        <el-form-item label="审核结果">
                            <el-select v-model="dialogExamineList.isApproval" :disabled="isGoExamineButton">
                                <el-option label="不通过" value="0"></el-option>
                                <el-option label="通过" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form label-position="right" label-width="110px" :model="dialogExamineList">
                        <el-form-item label="审核意见">
                            <el-input v-model="dialogExamineList.approvalAdvice" :disabled="isGoExamineButton"
                                      type="textarea" style="width: 523px;"></el-input>
                        </el-form-item>
                    </el-form>
                    <div v-if="jurisdiction.auditingApply" style="text-align: right;">
                        <el-button  v-if="!isGoExamineButton" @click="submitExamine" type="primary">提交审核</el-button>
                    </div>
                </div>
            </div>
            <div v-else style="padding-bottom: 20px;" :style="dialogHeight">
                <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px" :model="tableExamineHistoryList">
                    <el-form-item label="申请人"><el-input v-model="tableExamineHistoryList.applicantName" disabled></el-input></el-form-item>
                    <el-form-item label="申请时间"><el-input v-model="tableExamineHistoryList.applyTime" disabled></el-input></el-form-item>
                </el-form>
                <el-form label-position="right" label-width="110px" :model="tableExamineHistoryList" style="width: 99%;">
                    <el-form-item label="申请前内容">
                        <quill-editor v-model="tableExamineHistoryList.beforeContent"></quill-editor>
                    </el-form-item>
                    <el-form-item label="申请后内容">
                        <quill-editor v-model="tableExamineHistoryList.afterContent"></quill-editor>
                    </el-form-item>
                </el-form>
            </div>
        </el-dialog>

        <!-- 发放与回收 -->
        <el-dialog :title="dialogGrantRecoveryTitle" width="700px" class="GrantRecovery-dialog" :visible.sync="isGrantRecoveryDialog" :close-on-click-modal="false">
            <el-form :inline="true" class="demo-form-inline" label-position="right" label-width="110px"
                     :model="dialogGrantRecoveryList">
                <el-form-item label="发放人">
                    <el-input v-model="dialogGrantRecoveryList.issuerName" disabled></el-input>
                </el-form-item>
                <el-form-item label="接收时间">
                    <el-input v-model="dialogGrantRecoveryList.acceptTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放版本">
                    <el-input v-model="dialogGrantRecoveryList.versionCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="发放数量">
                    <el-input type="number" v-model="dialogGrantRecoveryList.num"
                              :disabled="dialogGrantRecoveryTitle !== '发放'"></el-input>
                </el-form-item>
                <el-form-item label="接收人">

                    <el-input v-if="dialogGrantRecoveryTitle !== '发放'" v-model="dialogGrantRecoveryList.accepterName" disabled></el-input>
                    <el-select v-else v-model="dialogGrantRecoveryList.accepter">
                        <el-option
                                v-for="item in userList"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <el-form v-if="dialogGrantRecoveryTitle !== '发放'" :inline="true" class="demo-form-inline"
                     label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="回收人">
                    <el-input v-model="dialogGrantRecoveryList.recyclingPersonName" disabled></el-input>
                </el-form-item>
                <el-form-item label="回收时间">
                    <el-input v-model="dialogGrantRecoveryList.recyclingTime" disabled></el-input>
                </el-form-item>
            </el-form>
            <el-form v-if="dialogGrantRecoveryTitle !== '发放'" :inline="true" class="demo-form-inline"
                     label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="回收版本">
                    <el-input v-model="dialogGrantRecoveryList.recyclingVersionCode"></el-input>
                </el-form-item>
            </el-form>
            <el-form label-position="right" label-width="110px" :model="dialogGrantRecoveryList">
                <el-form-item label="备注">
                    <el-input v-model="dialogGrantRecoveryList.remark" type="textarea" style="width: 522px;"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="jurisdiction.addPrintGrantInfo"  type="primary" @click="submitGrantRecoveryDialogList"
                           :disabled="!isDialogGrantRecoveryButton">确 定
                </el-button>
            </div>
        </el-dialog>

        <!-- 培训 -->
        <el-dialog :title="dialogTrainTitle" width="600px" class="GrantRecovery-dialog" :visible.sync="isTrainDialog" :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogTrainList">
                <el-form-item label="版本号">
                    <el-input v-model="dialogTrainList.versionCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训主持人">
                    <el-input v-model="dialogTrainList.trainerName" disabled></el-input>
                </el-form-item>
                <el-form-item label="培训时间">
                    <el-date-picker v-model="dialogTrainList.trainTime" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 100%;"></el-date-picker>
                </el-form-item>
                <el-form-item label="培训参与人员">
                    <el-input v-model="dialogTrainList.studyPersons" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="jurisdiction.addEditApplyInfo" @click="submitTrainDialogList" type="primary" :disabled="!isDialogTrainButton">确 定
                </el-button>
            </div>
        </el-dialog>

        <!-- 版本记录 -->
        <el-dialog title="编辑" width="600px" class="GrantRecovery-dialog" :visible.sync="isEditionDialog" :close-on-click-modal="false">
            <el-form label-position="right" label-width="110px" :model="dialogEditionList">
                <el-form-item label="版本号">
                    <el-input v-model="dialogEditionList.versionCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="文件编码">
                    <el-input v-model="dialogEditionList.fileCode" disabled></el-input>
                </el-form-item>
                <el-form-item label="发布人">
                    <el-input v-model="dialogEditionList.issuer" disabled></el-input>
                </el-form-item>
                <el-form-item label="发布时间">
                    <el-input v-model="dialogEditionList.issueTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="版本描述">
                    <el-input v-model="dialogEditionList.versionDesc" type="textarea"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="jurisdiction.addEditApplyInfo" @click="submitVersionData" type="primary" :disabled="!isDialogEditionButton">确 定</el-button>
            </div>
        </el-dialog>

        <!-- 打印弹框 -->
        <el-dialog title="打印" width="1000px" top="30px" :visible.sync="isPrintDialog" :close-on-click-modal="false">
            <div>
                <el-button v-if="jurisdiction.addPrintGrantInfo" type="primary" @click="PrintData">打印文件</el-button>
                <div :model="tablePrintData" id="printData" :style="tableDialogHeightPrint">
                    <h2 style="text-align: center;">{{tablePrintData.fileName}}</h2>
                    <ul class="printData_subTitle" style="overflow: hidden;margin: 10px 0 5px;">
                        <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">文件编码：</li>
                        <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{ tablePrintData.fileCode }}</li>
                        <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">发布时间</li>
                        <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{tablePrintData.issueTime}}</li>
                        <li style="list-style:none;float: left;font-size:12px;width: 10%;height: 20px;padding: 0 5px !important;text-align:right;">版本号：</li>
                        <li style="list-style:none;float: left;font-size:12px;width: 20%;height: 20px;padding: 0 5px !important;">{{tablePrintData.versionCode}}</li>
                    </ul>
                    <p style="font-size: 17px;margin: 0;">内容</p>
                    <div style="margin: 10px 0 0; padding-left: 40px;font-size:12px;color: #666;" v-html="tablePrintData.initialContent"></div>
                </div>
            </div>
        </el-dialog>
    </div>
</template>

<script>

    import VueUeditorWrap from 'vue-ueditor-wrap'
    import '../../../../../static/ueditor/ueditor.config.js'
    import '../../../../../static/ueditor/ueditor.all.js'
    import '../../../../../static/ueditor/lang/zh-cn/zh-cn.js'
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';
    import {quillEditor} from 'vue-quill-editor';
    import api from '@/axios/api.js'
    export default {
        name: "SJFile",
        components: {quillEditor,VueUeditorWrap},
        data() {
            let _token = sessionStorage.getItem("tokenId");
            let menuId = window.location.href.substr(window.location.href.lastIndexOf('/') + 1);
            return {
                tokenId: _token,
                menuId: menuId,
                fileId:'',
                fileGs: "",
                fileType: "",
                currentPage: 1,
                pagesize: 10,
                activeRecordName:'first',
                departments: [],
                userList: [],

                tableHeight: document.documentElement.clientHeight - 180,
                tableData: [],
                dialogHeight: {
                    height: (document.documentElement.clientHeight - 210) + 'px',
                    overflowY: 'auto'
                },
                instructionsHeight: {
                    height: (document.documentElement.clientHeight - 210) + 'px',
                    overflowY: 'auto'
                },

                //基本信息
                activeName:"first",
                isDialog: false,
                dialogTitle: "",
                isApprovalDisabled: false,
                isDialogDisabled:true,
                isDialogLockedDisabled:false,
                dialogList: {
                    initialContent: "",
                    approvalTime: "",
                    createTime: "",
                    fileApprover: "",
                    fileApproverName: "",
                    fileCode: "",
                    fileGs: "",
                    fileId: "",
                    fileName: "",
                    fileType: "",
                    fileUseScope: [],
                    fileWriter: "",
                    fileWriterName: "",
                    isApproval: "",
                    isLocked: "",
                    lastUpdateTime: "",
                    updateTimes: "",
                    versionCode: "",
                },
                //附件
                enclosureSrc: '/api/adscm/zltx/sjAttachment/upload',
                headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                resEnclosureData: {sjAttachment: ''},
                enclosureData: {
                    id: "",
                    fileId: "",
                    fileName: "",
                    filePath: "",
                    fileDesc: "",
                    uploadPerson: "",
                    uploadTime: "",
                    uploadPersonName: ""
                },
                enclosureList: [],




                //ueditor
                config: {
                    autoHeightEnabled: false,
                    initialFrameHeight: 500,
                    initialFrameWidth: '100%',
                    // 上传文件接口（这个地址是我为了方便各位体验文件上传功能搭建的临时接口，请勿在生产环境使用！！！）
                    autoFloatEnabled: true,　　//是否工具栏可浮动
                    initialContent:'请输入内容',   //初始化编辑器的内容,也可以通过textarea/script给值，看官网例子
                    autoClearinitialContent:true, //是否自动清除编辑器初始内容，注意：如果focus属性设置为true,这个也为真，那么编辑器一上来就会触发导致初始化的内容看不到了

                    BaseUrl: '',
                    //serverUrl:  "http://192.168.0.93:8889/mh/ueditor/config",
                    UEDITOR_HOME_URL: 'static/ueditor/'
                },



                //记录
                isDialogRecord: false,
                tableRecordHeight: document.documentElement.clientHeight - 290,

                //申请记录
                isApplyDialog: false,
                dialogApplyTitle:'',
                dialogApplyList:{
                    afterContent: "",
                    applicant: "",
                    applicantName: "",
                    applyTime: "",
                    approvalResult: "",
                    beforeContent: "",
                    fileCode: "",
                    fileId: "",
                    id: "",
                    isTrain: "",
                    initialContent: "",
                    updateTime: "",
                    updateType: "",
                    versionCode: "",
                },
                dialogApplyData:[],

                //审核相关
                isExamine: true,
                examineId:"",
                isSubmitExamine: false,
                isExamineDialog: false,
                dialogExamineTitle: '',
                isDialogExamineButton: true,
                tableExamineData: [],
                dialogExamineWidth: '',
                isGoExamineButton: true,
                dialogExamineList: {
                    approvalAdvice: "",
                    approvalTime: "",
                    approvaler: "",
                    approvalerName: "",
                    deptId: "",
                    deptName: "",
                    fileId: "",
                    id: "",
                    isApproval: "",
                    updateId: "",
                },
                tableExamineHistoryList: {
                    afterContent: "",
                    applicant: "",
                    applicantName: "",
                    applyTime: "",
                    beforeContent: "",
                },

                //回收与发放
                isGrantRecoveryDialog: false,
                dialogGrantRecoveryTitle: '',
                isDialogGrantRecoveryButton: true,
                dialogGrantRecoveryList: {
                    acceptTime: '',
                    accepter: "",
                    accepterName: "",
                    fileId: '',
                    id: '',
                    issueCode: "",
                    issuer: "",
                    issuerName: "",
                    num: '',
                    recyclingPerson: '',
                    recyclingPersonName: '',
                    recyclingTime: '',
                    recyclingVersionCode: '',
                    remark: '',
                    versionCode: '',
                },
                tableGrantRecoveryData: [],

                //培训记录
                isTrain: '',
                isTrainDialog: false,
                dialogTrainTitle: '',
                isDialogTrainButton: true,
                dialogTrainList: {
                    id: '',
                    fileId: '',
                    versionCode: '',
                    trainer: '',
                    trainerName: '',
                    studyPersons: '',
                    trainTime: '',
                },
                tableTrainData: [],

                //版本记录
                isEditionDialog: false,
                isDialogEditionButton: true,
                dialogEditionList: {
                    fileName: "",
                    fileCode: "",
                    fileContent: "",
                    fileId: "",
                    id: "",
                    issueTime: "",
                    issuer: "",
                    issuerName: "",
                    versionCode: "",
                    versionDesc: "",
                },
                tableEditionData: [],

                //打印
                isPrintDialog: false,
                tableDialogHeightPrint: {
                    height: (document.documentElement.clientHeight - 200) + 'px',
                    overflowY: 'auto',
                    paddingBottom: "60px"
                },
                tablePrintData:{
                    fileName: "",
                    fileCode: "",
                    initialContent: "",
                    fileId: "",
                    id: "",
                    issueTime: "",
                    issuer: "",
                    issuerName: "",
                    versionCode: "",
                    versionDesc: "",
                },

                jurisdiction:{
                    addBaseInfo: true,
                    addEditApplyInfo: true,
                    addPrintGrantInfo: true,
                    auditingApply: true,
                    fileRelease: true,
                }


            }
        },
        created() {
            this.getFileId();
            this.getJurisdiction();
            this.getDepartments();
            this.getUser();
        },
        methods: {
            getJurisdiction() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/system/menu/getMenuAllSrc/' + _this.menuId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        for (let i = 0; i < res.data.content.length; i++) {
                            let item = res.data.content[i];
                            debugger;
                            _this.jurisdiction[item.component] = item.menuShow;
                        }
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getFileId() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/QsFile/selectZltxListTree/' + _this.menuId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        let content = res.data.content;
                        _this.fileGs = content.fileGs;
                        _this.fileType = content.fileType;
                        _this.getTableData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getDepartments() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsQsfileDept/selectAllDept?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.departments = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            getUser() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/qsIssueRecyclingQsfile/queryUser?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.userList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("人员加载失败！请重新加载...");
                })
            },

            //基本信息
            getTableData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjFile/selectByFileId/' + _this.fileGs + '/' + _this.fileType + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {


                        _this.tableData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertList() {
                this.isDialog = true;
                this.dialogTitle = "添加";
                this.activeName = "first";
                this.isDialogDisabled = true;
                this.isDialogLockedDisabled = false;
                this.isApprovalDisabled = true;
                this.dialogList = {
                    initialContent: "",
                    approvalTime: "",
                    createTime: "",
                    fileApprover: "",
                    fileApproverName: "",
                    fileCode: "",
                    fileGs: this.fileGs,
                    fileId: "",
                    fileName: "",
                    fileType: this.fileType,
                    fileUseScope: [],
                    fileWriter: "",
                    fileWriterName: "",
                    isApproval: "",
                    isLocked: "",
                    lastUpdateTime: "",
                    updateTimes: "",
                    versionCode: "",
                };
            },
            updateList(row) {
                let self = this;
                 api.fileDetail(row.fileId).then(res=>{
                     let row = res.content[0];
                    self.fileId = row.fileId;
                    self.activeName = "first";
                    self.isDialogLockedDisabled = row.isLocked != "1" ? false : true;
                    self.isDialogDisabled = (row.isApproval == "1" && row.isLocked == 1) ? false : true;
                    self.isApprovalDisabled = row.isApproval != "1" ? false : true;
                    self.isDialog = true;
                    self.dialogTitle = "编辑";
                    self.dialogList = {
                        approvalTime: row.approvalTime ? row.approvalTime : "",
                        createTime: row.createTime ? row.createTime : "",
                        fileApprover: row.fileApprover ? row.fileApprover : "",
                        fileApproverName: row.fileApproverName ? row.fileApproverName : "",
                        fileCode: row.fileCode ? row.fileCode : "",
                        initialContent: row.initialContent,
                        fileGs: row.fileGs,
                        fileId: row.fileId,
                        fileName: row.fileName ? row.fileName : "",
                        fileType: row.fileType,
                        fileUseScope: row.fileUseScope ? row.fileUseScope : [],
                        fileWriter: row.fileWriter ? row.fileWriter : "",
                        fileWriterName: row.fileWriterName ? row.fileWriterName : "",
                        isApproval: row.isApproval ? row.isApproval : "",
                        isLocked: row.isLocked ? row.isLocked : "",
                        lastUpdateTime: row.lastUpdateTime ? row.lastUpdateTime : "",
                        updateTimes: row.updateTimes ? row.updateTimes : "",
                        versionCode: row.versionCode ? row.versionCode : "",
                    };

                    // 相关部门
                    let data = [];
                    let fileUseScope = self.dialogList.fileUseScope;
                    for (let i = 0; i < fileUseScope.length; i++) {
                        data.push(parseInt(fileUseScope[i] ))
                    }
                    self.dialogList.fileUseScope = data;
                })

            },
            submitList() {
                let _this = this;
                let url;
                if (_this.dialogTitle === "添加") {
                    url = '/api/adscm/zltx/sjFile/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogTitle === "编辑") {
                    url = '/api/adscm/zltx/sjFile/update?tokenId=' + _this.tokenId;
                }


                console.log( _this.dialogList.initialContent )

                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isDialog = false;
                        _this.getTableData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },

            getEnclosureData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjAttachment/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'}
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.enclosureList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            changeFileDesc() {
                this.enclosureData.fileId = this.fileId;
                this.resEnclosureData = {sjAttachment: JSON.stringify(this.enclosureData)};
            },
            submitDialogEnclosureDataOther() {
                this.resEnclosureData = {sjAttachment: JSON.stringify(this.enclosureData)};
                this.$refs.uploadEnclosure.submit();
            },
            uploadEnclosureSuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.$refs.uploadEnclosure.clearFiles();
                    this.enclosureData.fileDesc = "";
                    this.getEnclosureData();
                } else {
                    this.$message.error(response.desc)
                }
            },
            downloadAppendix(id) {
                window.location.href = "/api/adscm/zltx/sjAttachment/download/" + id;
            },
            deleteAppendix(row){
                console.log( row )
                let _this = this;
                this.$confirm('是否删除此文件?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    _this.$http({
                        url: '/api/adscm/zltx/sjAttachment/delete/'+row.id+'?tokenId='+_this.tokenId,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'},
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            _this.getEnclosureData();
                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {_this.$message.error("加载失败！请重新加载...");})

                }).catch(() => {});

            },

            //打印查看
            openPrint(row){
                let self =this;
                self.isPrintDialog = true;
                api.fileDetail(row.fileId).then(res=>{
                    self.tablePrintData=res.content[0];
                    self.tablePrintData.issueTime = row.approvalTime;
                })
            },


            //申请记录
            getRecordData(row) {
                let _this = this;
                this.isDialogRecord = true;
                this.fileId = row.fileId;
                this.$http({
                    url: '/api/adscm/zltx/sjApplyUpdateRecord/selectByFileId/' + row.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isDialogRecord = true;
                        _this.activeRecordName = 'first';
                        _this.dialogApplyData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertRecord(){
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjFile/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isApplyDialog= true;
                        _this.dialogApplyTitle='添加申请';
                        _this.dialogApplyList={
                            afterContent: "",
                            applicant: "",
                            applicantName: "",
                            applyTime: "",
                            approvalResult: "",
                            beforeContent: "",
                            fileCode: "",
                            fileId: _this.fileId,
                            id: "",
                            isTrain: "",
                            initialContent: res.data.content[0].initialContent,
                            updateTime: "",
                            updateType: "",
                            versionCode: "",
                        };
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            updateRecord(row){
                this.isApplyDialog= true;
                this.dialogApplyTitle='编辑申请';
                this.dialogApplyList={
                    afterContent: row.afterContent ? row.afterContent : "",
                    applicant: row.applicant ? row.applicant : "",
                    applicantName: row.applicantName ? row.applicantName : "",
                    applyTime: row.applyTime ? row.applyTime : "",
                    approvalResult: row.approvalResult ? row.approvalResult : "",
                    beforeContent: row.beforeContent ? row.beforeContent : "",
                    fileCode: row.fileCode ? row.fileCode : "",
                    fileId: row.fileId,
                    id: row.id,
                    isTrain: row.isTrain ? row.isTrain : "",
                    initialContent: row.initialContent,
                    updateTime: row.updateTime ? row.updateTime : "",
                    updateType: row.updateType ? row.updateType : "",
                    versionCode: row.versionCode ? row.versionCode : "",
                };
            },
            submitRecord() {
                let _this = this;
                let url;
                if (_this.dialogApplyTitle === "添加申请") {
                    url = '/api/adscm/zltx/sjApplyUpdateRecord/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogApplyTitle === "编辑申请") {
                    url = '/api/adscm/zltx/sjApplyUpdateRecord/update?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogApplyList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isApplyDialog = false;
                        _this.getRecordData(_this.dialogApplyList);
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })


            },

            getExamineData(){
              let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjApprovalRecord/selectByUpdateId/' + _this.examineId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableExamineData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            openExamine(row) {
                this.isExamineDialog = true;
                this.isSubmitExamine = false;
                this.dialogExamineTitle = '审核列表';
                this.dialogExamineWidth = '950px';
                this.examineId = row.id;
                this.getExamineData();
            },
            goExamine(row) {
                this.isSubmitExamine = true;
                this.dialogExamineList = {
                    approvalAdvice: row.approvalAdvice,
                    approvalTime: row.approvalTime,
                    approvaler: row.approvaler,
                    approvalerName: row.approvalerName,
                    deptId: row.deptId,
                    deptName: row.deptName,
                    fileId: row.fileId,
                    id: row.id,
                    isApproval: row.isApproval,
                    updateId: row.updateId,
                };
                this.isGoExamineButton = row.isApproval !== '1' ? false : true;
            },
            submitExamine() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjApprovalRecord/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogExamineList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isSubmitExamine = false;
                        _this.getExamineData();
                        _this.getRecordData(_this.dialogExamineList);
                        _this.getTableData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            openExamineHistory(row) {
                this.isExamineDialog = true;
                this.dialogExamineTitle = '申请历史列表';
                this.dialogExamineWidth = '70%';
                this.tableExamineHistoryList = {
                    afterContent: row.afterContent,
                    applicant: row.applicant,
                    applicantName: row.applicantName,
                    applyTime: row.applyTime,
                    beforeContent: row.beforeContent,
                };
            },

            // 回收与发放
            getGrantRecoveryData(){
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjIssueRecycling/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableGrantRecoveryData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertGrantRecoveryData() {
                let _this = this;
                _this.isGrantRecoveryDialog = true;
                _this.dialogGrantRecoveryTitle = '发放';
                _this.isDialogGrantRecoveryButton = true;
                _this.dialogGrantRecoveryList = {
                    acceptTime: '',
                    accepter: "",
                    accepterName: "",
                    fileId: _this.fileId,
                    id: '',
                    issueCode: "",
                    issuer: "",
                    issuerName: "",
                    num: '',
                    recyclingPerson: '',
                    recyclingPersonName: '',
                    recyclingTime: '',
                    recyclingVersionCode: '',
                    remark: '',
                    versionCode: '',
                }
            },
            updateGrantRecoveryData(row) {
                let _this = this;
                _this.isGrantRecoveryDialog = true;
                _this.dialogGrantRecoveryTitle = '回收';
                _this.isDialogGrantRecoveryButton = true;

                _this.dialogGrantRecoveryList = {
                    acceptTime: row.acceptTime,
                    accepter: row.accepter,
                    accepterName: row.accepterName,
                    fileId: row.fileId,
                    id: row.id,
                    issueCode: row.accepterName,
                    issuer: row.issuer,
                    issuerName: row.issuerName,
                    num: row.num,
                    recyclingPerson: row.recyclingPerson,
                    recyclingPersonName: row.recyclingPersonName,
                    recyclingTime: row.recyclingTime,
                    recyclingVersionCode: row.recyclingVersionCode,
                    remark: row.remark,
                    versionCode: row.versionCode
                }
            },
            submitGrantRecoveryDialogList() {
                let _this = this;
                let url;
                _this.isDialogGrantRecoveryButton = false;
                if (_this.dialogGrantRecoveryTitle === '发放') {
                    url = '/api/adscm/zltx/sjIssueRecycling/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogGrantRecoveryTitle === '回收') {
                    url = '/api/adscm/zltx/sjIssueRecycling/update?tokenId=' + _this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogGrantRecoveryList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isGrantRecoveryDialog = false;
                        _this.getGrantRecoveryData(_this.dialogGrantRecoveryList.fileId);
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogGrantRecoveryButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogGrantRecoveryButton = true;
                })


            },

            //培训
            getTrainData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjFileTrain/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableTrainData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            updateTrainData(row) {
                this.isTrainDialog = true;
                this.dialogTrainTitle = '编辑';
                this.isDialogTrainButton = true;
                this.dialogTrainList = {
                    id: row.id,
                    fileId: row.fileId,
                    versionCode: row.versionCode,
                    trainer: row.trainer,
                    trainerName: row.trainerName,
                    studyPersons: row.studyPersons,
                    trainTime: row.trainTime ? this.timestampToTime(row.trainTime) : '',
                }
            },
            submitTrainDialogList() {
                let _this = this;
                _this.isDialogTrainButton = false;
                _this.dialogTrainList.trainTime =  _this.timestampToTime(_this.dialogTrainList.trainTime);
                this.$http({
                    url: '/api/adscm/zltx/sjFileTrain/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogTrainList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isTrainDialog = false;
                        _this.getTrainData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogTrainButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogTrainButton = true;
                })
            },

            //版本记录
            getEditionData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjFileVersionRecord/selectByFileId/' + _this.fileId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.tableEditionData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            EditedVersionData(row) {
                this.isEditionDialog = true;
                this.dialogEditionList = {
                    fileName: row.fileName,
                    fileContent: row.fileContent,
                    id:row.id,
                    issuerName: row.issuerName,
                    fileCode: row.fileCode,
                    fileId: row.fileId,
                    issueTime: row.issueTime ? row.issueTime : '',
                    issuer: row.issuer ? row.issuer : '',
                    versionCode: row.versionCode,
                    versionDesc: row.versionDesc,
                };
            },
            updateEditionData(row) {
                this.isPrintDialog = true;
                this.tablePrintData = row;
            },
            submitVersionData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/zltx/sjFileVersionRecord/update?tokenId=' + _this.tokenId,
                    method: 'POST',
                    headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                    data: _this.dialogEditionList
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isEditionDialog = false;
                        _this.getEditionData();
                    } else {
                        _this.$message.error(res.data.desc);
                        _this.isDialogEditionButton = true;
                    }
                }).catch(function (error) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.isDialogEditionButton = true;
                })
            },


            handleClick(tab,event){
                this.enclosureSrc = "/api/adscm/zltx/sjAttachment/upload?tokenId=" + this.tokenId;
                if (tab.name === "second") {
                    this.getEnclosureData();

                }
            },
            handleRecordClick(tab,event){
                if (tab.name === "second") {
                     this.getGrantRecoveryData();
                } else if (tab.name === "third") {
                    this.getTrainData();
                } else if (tab.name === "four") {
                    this.getEditionData();
                }
            },
            timestampToTime(timestamp) {
                let date = new Date(timestamp);
                let Y = date.getFullYear() + '-';
                let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                return timestamp ? Y + M + D + h + m + '00' : '';
            },
            formatContentType(row, column, cellValue, index) {
                return cellValue ? (cellValue === "2" ? '目的' : (cellValue === "3" ? '适用范围' : (cellValue === "4" ? '职责' : (cellValue === "5" ? '定义/缩写语' : (cellValue === "6" ? '流程图' : (cellValue === "7" ? '程序' : (cellValue === "8" ? '相关文件' : (cellValue === "9" ? '相关记录' : (cellValue === "10" ? '附件' : ''))))))))) : '';
            },
            formatIsResult(row, column, cellValue, index) {
                return cellValue ? (cellValue == 0 ? '不通过' : (cellValue == 1 ? '通过' : (cellValue == -1 ? '待审核' : ''))) : '';
            },
            handleSizeChange(size) {
                this.pagesize = size;
            },
            handleCurrentChange  (currentPage) {
                this.currentPage = currentPage;
            },


        }

    }
</script>

<style scoped>
    @import "qualitySystem.css";
    .operation {
        margin-bottom: 10px;
    }
    .operation .serch-parent {
        width: 200px;
    }
</style>
